home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-21 | 2.7 KB | 132 lines | [TEXT/CWIE] |
- /*------------------------------------------------------------------------------
- #
- # NewsTicker, my Hack for 1997
- #
- # TickerReadHeadlines.cp - Handle the classes that do the dirty work.
- #
- ------------------------------------------------------------------------------*/
- #include "ICAPI.h" // Internet config stuff
-
- #include "TickerGlobals.h" /* bring in all the #defines for NewsTicker */
- #include "TickerReadHeadlines.h"
- #include "TickerWindowHandler.h"
- #include "TickerCheckWebs.h"
- #include "NewsComExtractor.h"
- #include "AppleExtractor.h"
- #include "CNNExtractor.h"
-
- // Globals for the URL launching
-
- ICInstance gTheInst = nil;
- short gICInitted = false;
- //
- // Handle the two derived HTML parser classes, to read the headlines and put them in
- // the scrolling list. Also put the changed web pages into the list
- //
- void FillTheHeadlines( sMyDataPtr gGlobalsPtr )
- {
- short index;
-
- gGlobalsPtr->MsgCount = 0;
- gGlobalsPtr->MsgWidth = 0;
- for (index = 0; index<maxHeadlines; index++)
- {
- gGlobalsPtr->theHeadlines[index].Subject[0] = 0;
- }
-
- UpdateChangedWebs(gGlobalsPtr);
-
- if (gThePrefs.DoReadCNN)
- {
- LoadCNN(gGlobalsPtr);
- }
-
- if (gThePrefs.DoReadNews)
- {
- LoadNewsCom(gGlobalsPtr);
- }
-
- if (gThePrefs.DoReadApple)
- {
- LoadAppleCom(gGlobalsPtr);
- }
-
- InitCursor();
- }
- //
- // Find out if we need to reload pages and, if so, do so
- //
- void MaybeReload( sMyDataPtr gGlobalsPtr )
- {
- if (gThePrefs.DoReadCNN)
- {
- if (MustReloadCNN(gGlobalsPtr))
- {
- LoadCNN(gGlobalsPtr);
- CalcOffsets(gGlobalsPtr);
- }
- }
-
- if (gThePrefs.DoReadNews)
- {
- if (MustReloadNewsCom(gGlobalsPtr))
- {
- LoadNewsCom(gGlobalsPtr);
- CalcOffsets(gGlobalsPtr);
- }
- }
-
- if (gThePrefs.DoReadApple)
- {
- if (MustReloadAppleCom(gGlobalsPtr))
- {
- LoadAppleCom(gGlobalsPtr);
- CalcOffsets(gGlobalsPtr);
- }
- }
-
- CheckChangedWebPages(gGlobalsPtr);
- InitCursor();
- }
- //
- // When an item is double-clicked on, launch the URL. (And, if it's a web page,
- // remove it from the list of changed pages).
- //
- void OpenItem(sMyDataPtr gGlobalsPtr, short whichitem)
- {
- if (gGlobalsPtr->theHeadlines[whichitem].cicnResID == kWebIconID)
- UpdateAWebEntry(gGlobalsPtr, whichitem);
- else LaunchURL(gGlobalsPtr->theHeadlines[whichitem].URL);
- }
- //
- // Initialize Internet Config
- //
- void InitInternetConfig(void)
- {
- ICError theerr;
-
- if (!gICInitted)
- {
- theerr = ICStart(&gTheInst, 'NwTk');
-
- if (theerr==noErr)
- {
- theerr = ICFindConfigFile(gTheInst, 0, nil);
- }
- if (theerr == noErr)
- gICInitted = true;
- }
-
- }
- //
- // Launch a URL using Internet Config
- //
- void LaunchURL(Str255 theURL)
- {
- long selstart = 0;
- long selend = theURL[0];
-
- if (gICInitted)
- ICLaunchURL (gTheInst, "\p", (char*)&theURL[1], theURL[0], &selstart, &selend);
- }
-